package com.guodi.model.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.guodi.model.entity.DiagnosisProblemScene;
import com.guodi.model.mapper.DiagnosisProblemSceneMapper;
import com.guodi.model.service.IDiagnosisProblemSceneService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;

/**
 * @描述：诊断分析-问题场景管理表 服务类
 * @作者: 徐金洲
 * @日期: 2023-05-05
 */
@Service
public class DiagnosisProblemSceneServiceImpl extends ServiceImpl<DiagnosisProblemSceneMapper, DiagnosisProblemScene> implements IDiagnosisProblemSceneService {

    @Resource
    private DiagnosisProblemSceneMapper diagnosisProblemSceneMapper;

    @Override
    public Page listByEntity(Page page, DiagnosisProblemScene diagnosisProblemScene) {
        LambdaQueryWrapper<DiagnosisProblemScene> queryWrapper = (new QueryWrapper()).lambda();
        if (org.apache.commons.lang.StringUtils.isNotBlank(diagnosisProblemScene.getProblemName())) {
            queryWrapper.like(DiagnosisProblemScene::getProblemName, diagnosisProblemScene.getProblemName());
        }
        queryWrapper.orderByDesc(DiagnosisProblemScene::getCreateTime);
        page = diagnosisProblemSceneMapper.selectPage(page, queryWrapper);
        List<DiagnosisProblemScene> list = page.getRecords();
        page.setRecords(list);
        return page;
    }
}
